package com.ccp.dev.qbdms.enums;

import com.ccp.dev.system.model.Dictionary;
import java.util.List;
import org.apache.commons.compress.utils.Lists;

/**
 * ClassDescribe:
 *
 * @author :milihao
 */
public enum FlowStatusEnum {

	/**
	 * 未提交
	 */
	NOT_SUBMIT("0", "待提交", true, true),
	/**
	 * 审批中
	 */
	APPROVAL_ING("1", "审批中", false, false),
	APPROVAL_ING2("2", "审批中", false, false),
	APPROVAL_ING3("3", "审批中", false, false),
	APPROVAL_ING4("4", "审批中", false, false),
	APPROVAL_ING5("5", "审批中", false, false),
	APPROVAL_ING6("6", "审批中", false, false),
	APPROVAL_ING7("7", "审批中", false, false),
	APPROVAL_ING8("8", "审批中", false, false),
	/**
	 * 审批结束
	 */
	DONE("99", "审批完成", false, true);


	private String value;
	private String name;
	private boolean isEdit;
	private boolean isDel;


	FlowStatusEnum(String value, String name, boolean isEdit, boolean isDel) {
		this.value = value;
		this.name = name;
		this.isEdit = isEdit;
		this.isDel = isDel;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public boolean isEdit() {
		return isEdit;
	}

	public void setEdit(boolean edit) {
		isEdit = edit;
	}

	public boolean isDel() {
		return isDel;
	}

	public void setDel(boolean del) {
		isDel = del;
	}


	/**
	 * 根据对应的值获取枚举实例方法
	 */
	public static FlowStatusEnum getEnumByValue(String value) {
		if (value == null) {
			value = "0";
		}
		for (FlowStatusEnum item : FlowStatusEnum.values()) {
			if (item.getValue().equals(value)) {
				return item;
			}
		}
		return null;
	}

	public static String getFlowStatusQueryFilter(String value) {
		if (value.equals(FlowStatusEnum.NOT_SUBMIT.getValue())) {
			return FlowStatusEnum.NOT_SUBMIT.getValue();
		} else if (value.equals(FlowStatusEnum.DONE.getValue())) {
			return FlowStatusEnum.DONE.value;
		} else {
			StringBuilder sb = new StringBuilder();
			for (FlowStatusEnum ele : values()) {
				if (Integer.parseInt(ele.getValue()) >= 1 && Integer.parseInt(ele.getValue()) < 99) {
					sb.append("'" + ele.getValue() + "',");
				}
			}
			return sb.toString().substring(0, sb.length() - 1);
		}
	}

	public static List<Dictionary> getFlowStatusList() {
		List<Dictionary> dictionaryList = Lists.newArrayList();
		Dictionary dictionary;
		for (FlowStatusEnum ele : values()) {
			if (Integer.parseInt(ele.getValue()) > 1 && Integer.parseInt(ele.getValue()) < 99) {
				continue;
			}
			dictionary = new Dictionary();
			dictionary.setItemName(ele.getName());
			dictionary.setItemValue(ele.getValue());
			dictionaryList.add(dictionary);
		}
		return dictionaryList;
	}
}
